<template>
  <div class="inbound-container">
    <el-form :inline="true" label-width="120px" :model="form">
      <el-form-item :label="translate('凭证类型') + '：'">
        <div class="item">{{ form.VoucherType }}</div>
      </el-form-item>
      <el-form-item :label="translate('计划单号') + '：'">
        <div class="item">{{ form.PlanNo }}</div>
      </el-form-item>
      <el-form-item :label="translate('工厂') + '：'">
        <div class="item">{{ form.Factory }}</div>
      </el-form-item>
      <el-form-item :label="translate('采购组') + '：'">
        <div class="item">
          {{ form.PurchaseGroup }}
        </div>
      </el-form-item>
      <el-form-item :label="translate('供货工厂') + '：'">
        <div class="item">{{ form.SupFactory }}</div>
      </el-form-item>
      <el-form-item :label="translate('分配类别') + '：'">
        <div class="item">{{ form.SubjectCate }}</div>
      </el-form-item>
      <el-form-item :label="translate('交货时间') + '：'">
        <div class="item">{{ form.DeliveryDate }}</div>
      </el-form-item>
      <el-form-item :label="translate('成本中心') + '：'">
        <div class="item">
          {{ form.CostCenter }}
        </div>
      </el-form-item>
      <el-form-item :label="translate('WBS元素') + '：'">
        <div class="item">{{ form.WBSele }}</div>
      </el-form-item>
      <el-form-item :label="translate('投资名称') + '：'">
        <div class="item">{{ form.InvestName }}</div>
      </el-form-item>
      <!-- <el-form-item :label="translate('大类号') + '：'">
        <div class="item">{{ form.LCNo }}</div>
      </el-form-item> -->
      <el-form-item :label="translate('技术标准') + '：'">
        <div class="item">{{ form.TechLevel }}</div>
      </el-form-item>
      <el-form-item :label="translate('备注') + '：'">
        <div>{{ form.Remark }}</div>
      </el-form-item>
    </el-form>
    <el-table ref="multipleTable" border :data="tableData">
      <el-table-column :label="translate('类别')" prop="ItemCate" />
      <el-table-column :label="translate('物资编码')" prop="ItemCode" />
      <el-table-column
        :label="translate('物资名称')"
        min-width="100"
        prop="ItemName"
      />
      <el-table-column :label="translate('规格')" prop="ItemSpec" />
      <el-table-column
        :label="translate('物资组')"
        min-width="120"
        prop="ItemGroup"
        show-overflow-tooltip
      />
      <el-table-column
        :label="translate('物资组名称')"
        prop="ItemGroupName"
        show-overflow-tooltip
      />
      <el-table-column :label="translate('数量')" prop="Qty" />
      <el-table-column :label="translate('价格')" min-width="80" prop="Price" />
      <el-table-column :label="translate('计量单位')" prop="ItemUnit" />
      <el-table-column :label="translate('金额')" prop="TotalAmount" />
      <el-table-column :label="translate('用途')" prop="Purpose" />
    </el-table>
    <div class="pagination">
      <el-pagination
        background
        :current-page="pageNo"
        :layout="'total, sizes, prev, pager, next, jumper'"
        :page-size="pageSize"
        :total="total"
        @current-change="handleCurrentchiled"
        @size-change="handleSizechiled"
      />
    </div>
  </div>
</template>

<script lang="ts" setup>
  import { ref } from 'vue'
  import { Wms_planGetDetailPageData } from '@/api/form'
  import { translate } from '@/i18n'
  const props = defineProps<{
    id: string
  }>()
  const form: any = ref({})
  const tableData: any = ref([])
  const id = props.id || ''
  const pageNo = ref(1)
  const pageSize = ref(10)
  const total = ref(0)
  const getTableData = async () => {
    const params = {
      pageNo: 1,
      pageSize: 10,
      total: 0,
      tableName: '',
      sort: '',
      order: '',
      wheres: '',
      export: true,
      value: id,
    }
    const data = await Wms_planGetDetailPageData(params)
    tableData.value = data.rows || []
    form.value = data.master || {}
  }
  const handleCurrentchiled = (val: number) => {
    pageNo.value = val
  }
  const handleSizechiled = (val: number) => {
    pageSize.value = val
  }

  onMounted(() => {
    getTableData()
  })
</script>

<style lang="scss" scoped>
  .inbound-container {
    .item {
      width: 160px;
    }
  }
</style>
